/*****************************************************************************/
/*                                                                           */
/*    Domino Operation System Driver Module                                  */
/*                                                                           */
/*    Copyright (C) 2011 Laszlo Arvai                                        */
/*                                                                           */
/*    ------------------------------------------------------------------     */
/*    I2C Driver for PIC24 series                                            */
/*****************************************************************************/

#ifndef __drvI2C_H
#define __drvI2C_H

///////////////////////////////////////////////////////////////////////////////
// Include files
#include <krnlTypes.h>

///////////////////////////////////////////////////////////////////////////////
// Constants

///////////////////////////////////////////////////////////////////////////////
// Types
typedef enum _drvI2CRWMode
{
	drvI2C_WRITE = 0,
	drvI2C_READ = 1
} drvI2CRWMode;

typedef enum _drvI2CACK
{
	drvI2C_ACK,
	drvI2C_NACK
} drvI2CACK;

///////////////////////////////////////////////////////////////////////////////
// Includes

// I2C unit (general)
void			drvI2CInit(void);
dosBool		drvI2CStart(drvI2CRWMode in_mode, dosByte in_address);
dosBool		drvI2CRestart(drvI2CRWMode in_mode, dosByte in_address);
void			drvI2CStop(void);
dosByte		drvI2CWriteByte(dosByte in_data);
dosByte		drvI2CReadByte(drvI2CACK in_ack);

// I2C unit #1
void			drvI2C1Init(void);
dosBool		drvI2C1Start(drvI2CRWMode in_mode, dosByte in_address);
dosBool		drvI2C1Restart(drvI2CRWMode in_mode, dosByte in_address);
void			drvI2C1Stop(void);
dosByte		drvI2C1WriteByte(dosByte in_data);
dosByte		drvI2C1ReadByte(drvI2CACK in_ack);

// I2C unit #2
void			drvI2C2Init(void);
dosBool		drvI2C2Start(drvI2CRWMode in_mode, dosByte in_address);
dosBool		drvI2C2Restart(drvI2CRWMode in_mode, dosByte in_address);
void			drvI2C2Stop(void);
dosByte		drvI2C2WriteByte(dosByte in_data);
dosByte		drvI2C2ReadByte(drvI2CACK in_ack);

// I2C unit #3
void			drvI2C3Init(void);
dosBool		drvI2C3Start(drvI2CRWMode in_mode, dosByte in_address);
dosBool		drvI2C3Restart(drvI2CRWMode in_mode, dosByte in_address);
void			drvI2C3Stop(void);
dosByte		drvI2C3WriteByte(dosByte in_data);
dosByte		drvI2C3ReadByte(drvI2CACK in_ack);

#endif
